home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / Include / sun4.md / machMon.h < prev    next >
C/C++ Source or Header  |  1990-10-19  |  9KB  |  321 lines

  1. /*
  2.  * machMon.h --
  3.  *
  4.  *     Structures, constants and defines for access to the sun monitor.
  5.  *     These are translated from the sun monitor header file "sunromvec.h".
  6.  *
  7.  * NOTE: The file keyboard.h in the monitor directory has all sorts of useful
  8.  *       keyboard stuff defined.  I haven't attempted to translate that file
  9.  *       because I don't need it.  If anyone wants to use it, be my guest.
  10.  *
  11.  * Copyright (C) 1985 Regents of the University of California
  12.  * All rights reserved.
  13.  *
  14.  *
  15.  * $Header: /sprite/src/kernel/mach/sun4.md/RCS/machMon.h,v 9.1 90/10/12 14:55:58 mgbaker Exp $ SPRITE (Berkeley)
  16.  */
  17.  
  18. #ifndef _MACHMON
  19. #define _MACHMON
  20.  
  21. /*
  22.  * The memory addresses for the PROM, and the EEPROM.
  23.  * On the sun2 these addresses are actually 0x00EF??00
  24.  * but only the bottom 24 bits are looked at so these still
  25.  * work ok.
  26.  */
  27.  
  28. #define EEPROM_BASE     0xffd04000
  29. #define PROM_BASE       0xffe81000
  30.  
  31. /*
  32.  * The table entry that describes a device.  It exists in the PROM; a
  33.  * pointer to it is passed in MachMonBootParam.  It can be used to locate
  34.  * PROM subroutines for opening, reading, and writing the device.
  35.  *
  36.  * When using this interface, only one device can be open at once.
  37.  *
  38.  * NOTE: I am not sure what arguments boot, open, close, and strategy take.
  39.  * What is here is just translated verbatim from the sun monitor code.  We
  40.  * should figure this out eventually if we need it.
  41.  */
  42.  
  43. typedef struct {
  44.     char    devName[2];        /* The name of the device */
  45.     int    (*probe)();        /* probe() --> -1 or found controller
  46.                        number */
  47.     int    (*boot)();        /* boot(bp) --> -1 or start address */
  48.     int    (*open)();        /* open(iobp) --> -1 or 0 */
  49.     int    (*close)();        /* close(iobp) --> -1 or 0 */
  50.     int    (*strategy)();        /* strategy(iobp,rw) --> -1 or 0 */
  51.     char    *desc;            /* Printable string describing dev */
  52.     /* Sun4 has struct devinfo here.  Do I need it? */
  53. } MachMonBootTable;
  54.  
  55. /*
  56.  * Structure set up by the boot command to pass arguments to the program that
  57.  * is booted.
  58.  */
  59.  
  60. typedef struct {
  61.     char        *argPtr[8];    /* String arguments */
  62.     char        strings[100];    /* String table for string arguments */
  63.     char        devName[2];    /* Device name */
  64.     int        ctlrNum;    /* Controller number */
  65.     int        unitNum;    /* Unit number */
  66.     int        partNum;    /* Partition/file number */
  67.     char        *fileName;    /* File name, points into strings */
  68.     MachMonBootTable   *bootTable;    /* Points to table entry for device */
  69. } MachMonBootParam;
  70.  
  71. /*
  72.  * Here is the structure of the vector table which is at the front of the boot
  73.  * rom.  The functions defined in here are explained below.
  74.  *
  75.  * NOTE: This struct has references to the structures keybuf and globram which
  76.  *       I have not translated.  If anyone needs to use these they should
  77.  *       translate these structs into Sprite format.
  78.  */
  79.  
  80. typedef struct {
  81.     char        *initSp;        /* Initial system stack ptr
  82.                          * for hardware */
  83.     void        (*startMon)();        /* Initial PC for hardware */
  84.  
  85.     int        *diagberr;        /* Bus err handler for diags */
  86.  
  87.     /*
  88.      * Monitor and hardware revision and identification
  89.      */
  90.  
  91.     MachMonBootParam **bootParam;        /* Info for bootstrapped pgm */
  92.      unsigned int    *memorySize;        /* Usable memory in bytes */
  93.  
  94.     /*
  95.      * Single-character input and output
  96.      */
  97.  
  98.     unsigned char    (*getChar)();        /* Get char from input source */
  99.     void        (*putChar)();        /* Put char to output sink */
  100.     int        (*mayGet)();        /* Maybe get char, or -1 */
  101.     int        (*mayPut)();        /* Maybe put char, or -1 */
  102.     unsigned char    *echo;            /* Should getchar echo? */
  103.     unsigned char    *inSource;        /* Input source selector */
  104.     unsigned char    *outSink;        /* Output sink selector */
  105.  
  106.     /*
  107.      * Keyboard input (scanned by monitor nmi routine)
  108.      */
  109.  
  110.     int        (*getKey)();        /* Get next key if one exists */
  111.     void        (*initGetKey)();    /* Initialize get key */
  112.     unsigned int    *translation;        /* Kbd translation selector
  113.                            (see keyboard.h in sun
  114.                             monitor code) */
  115.     unsigned char    *keyBid;        /* Keyboard ID byte */
  116.     int        *screen_x;        /* V2: Screen x pos (R/O) */
  117.     int        *screen_y;        /* V2: Screen y pos (R/O) */
  118.     struct keybuf    *keyBuf;        /* Up/down keycode buffer */
  119.  
  120.     /*
  121.      * Monitor revision level.
  122.      */
  123.  
  124.     char        *monId;
  125.  
  126.     /*
  127.      * Frame buffer output and terminal emulation
  128.      */
  129.  
  130.     void        (*fbWriteChar)();    /* Write a character to FB */
  131.     int        *fbAddr;        /* Address of frame buffer */
  132.     char        **font;            /* Font table for FB */
  133.     void        (*fbWriteStr)();    /* Quickly write string to FB */
  134.  
  135.     /*
  136.      * Reboot interface routine -- resets and reboots system.  No return.
  137.      */
  138.  
  139.     void        (*reBoot)();        /* e.g. reBoot("xy()vmunix") */
  140.  
  141.     /*
  142.      * Line input and parsing
  143.      */
  144.  
  145.     unsigned char    *lineBuf;        /* The line input buffer */
  146.     unsigned char    **linePtr;        /* Cur pointer into linebuf */
  147.     int        *lineSize;        /* length of line in linebuf */
  148.     void        (*getLine)();        /* Get line from user */
  149.     unsigned char    (*getNextChar)();    /* Get next char from linebuf */
  150.     unsigned char    (*peekNextChar)();    /* Peek at next char */
  151.     int        *fbThere;        /* =1 if frame buffer there */
  152.     int        (*getNum)();        /* Grab hex num from line */
  153.  
  154.     /*
  155.      * Print formatted output to current output sink
  156.      */
  157.  
  158.     int        (*printf)();        /* Similar to "Kernel printf" */
  159.     void        (*printHex)();        /* Format N digits in hex */
  160.  
  161.     /*
  162.      * Led stuff
  163.      */
  164.  
  165.     unsigned char    *leds;            /* RAM copy of LED register */
  166.     void        (*setLeds)();        /* Sets LED's and RAM copy */
  167.  
  168.     /*
  169.      * Non-maskable interrupt  (nmi) information
  170.      */
  171.  
  172.     void        (*nmiAddr)();        /* Addr for level 7 vector */
  173.     void        (*abortEntry)();    /* Entry for keyboard abort */
  174.     int        *nmiClock;        /* Counts up in msec */
  175.  
  176.     /*
  177.      * Frame buffer type: see <sun/fbio.h>
  178.      */
  179.  
  180.     int        *fbType;
  181.  
  182.     /*
  183.      * Assorted other things
  184.      */
  185.  
  186.     unsigned int    romvecVersion;        /* Version # of Romvec */
  187.     struct globram  *globRam;        /* monitor global variables */
  188.     Address        kbdZscc;        /* Addr of keyboard in use */
  189.  
  190.     int        *keyrInit;        /* ms before kbd repeat */
  191.     unsigned char    *keyrTick;         /* ms between repetitions */
  192.     unsigned int    *memoryAvail;        /* V1: Main mem usable size */
  193.     long        *resetAddr;        /* where to jump on a reset */
  194.     long        *resetMap;        /* pgmap entry for resetaddr */
  195.                         /* Really struct pgmapent *  */
  196.     void        (*exitToMon)();        /* Exit from user program */
  197.     unsigned char    **memorybitmap;        /* V1: &{0 or &bits} */
  198.     void        (*setcxsegmap)();    /* Set seg in any context */
  199.     void        (**vector_cmd)();    /* V2: Handler for 'v' cmd */
  200.     unsigned long    *expectedTrapSig;    /* V3: Location of the expected
  201.                          * trap signal.  Was trap
  202.                          * expected or not? */
  203.     unsigned long    *trapVectorBaseTable;    /* V3: Address of the TRAP
  204.                          * VECTOR TABLE which exists
  205.                          * in RAM. */
  206.     int        dummy1z;
  207.     int        dummy2z;
  208.     int        dummy3z;
  209.     int        dummy4z;
  210. } MachMonRomVector;
  211.  
  212. /*
  213.  * Functions defined in the vector:
  214.  *
  215.  *
  216.  * getChar -- Return the next character from the input source
  217.  *
  218.  *     unsigned char getChar()
  219.  *
  220.  * putChar -- Write the given character to the output source.
  221.  *
  222.  *     void putChar(ch)
  223.  *       char ch;
  224.  *
  225.  * mayGet -- Maybe get a character from the current input source.  Return -1
  226.  *           if don't return a character.
  227.  *
  228.  *     int mayGet()
  229.  *
  230.  * mayPut -- Maybe put a character to the current output source.   Return -1
  231.  *           if no character output.
  232.  *
  233.  *    int  mayPut(ch)
  234.  *        char ch;
  235.  *
  236.  * getKey -- Returns a key code (if up/down codes being returned),
  237.  *          a byte of ASCII (if that's requested),
  238.  *          NOKEY (if no key has been hit).
  239.  *
  240.  *    int getKey()
  241.  *
  242.  * initGetKey --  Initialize things for get key.
  243.  *
  244.  *    void initGetKey()
  245.  *
  246.  * fbWriteChar -- Write a character to the frame buffer
  247.  *
  248.  *    void fwritechar(ch)
  249.  *        unsigned char ch;
  250.  *
  251.  * fbWriteStr -- Write a string to the frame buffer.
  252.  *
  253.  *       void fwritestr(addr,len)
  254.  *          register unsigned char *addr;    / * String to be written * /
  255.  *          register short len;            / * Length of string * /
  256.  *
  257.  * getLine -- read the next input line into a global buffer
  258.  *
  259.  *    void getline(echop)
  260.  *          int echop;    / * 1 if should echo input, 0 if not * /
  261.  *
  262.  * getNextChar -- return the next character from the global line buffer.
  263.  *
  264.  *    unsigned char getNextChar()
  265.  *
  266.  * peekNextChar -- look at the next character in the global line buffer.
  267.  *
  268.  *    unsigned char peekNextChar()
  269.  *
  270.  * getNum -- Grab hex num from the global line buffer.
  271.  *
  272.  *    int getNum()
  273.  *
  274.  * printf -- Scaled down version of C library printf.  Only %d, %x, %s, and %c
  275.  *          are recognized.
  276.  *
  277.  * printhex -- prints rightmost <digs> hex digits of <val>
  278.  *
  279.  *      void printhex(val,digs)
  280.  *          register int val;
  281.  *             register int digs;
  282.  *
  283.  * abortEntry -- Entry for keyboard abort.
  284.  *
  285.  *     void abortEntry()
  286.  */
  287.  
  288. /*
  289.  * Where the rom vector is defined.  Note that on a Sun-2 the address is
  290.  * 0xef0000.  This is ok because only the low order 24-bits will be looked at.
  291.  */
  292.  
  293. #define    romVectorPtr    ((MachMonRomVector *) PROM_BASE)
  294.  
  295. /*
  296.  * Functions and defines to access the monitor.
  297.  */
  298.  
  299. #define Mach_MonPrintf (romVectorPtr->printf)
  300.  
  301. extern void Mach_MonPutChar _ARGS_((int ch));
  302. extern int Mach_MonMayPut _ARGS_((int ch));
  303. extern void Mach_MonAbort _ARGS_((void));
  304. extern void Mach_MonReboot _ARGS_((char *rebootString));
  305. extern    void    Mach_MonTrap _ARGS_((Address address_to_trap_to));
  306. extern void Mach_MonStartNmi _ARGS_((void));
  307. extern void Mach_MonStopNmi _ARGS_((void));
  308.  
  309. /*
  310.  * These routines no longer work correctly with new virtual memory.
  311.  * IS THIS TRUE FOR SUN4 TOO?
  312.  */
  313. #define Mach_MonGetChar (romVectorPtr->getChar)
  314. #define Mach_MonGetLine (romVectorPtr->getLine)
  315. #define Mach_MonGetNextChar (romVectorPtr->getNextChar)
  316. #define Mach_MonPeekNextChar (romVectorPtr->peekNextChar)
  317.  
  318.  
  319.  
  320. #endif /* _MACHMON */
  321.